home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Security / FULL - Iolo Drive Scrubber 3.5 / DriveScrubber3.exe / {code_GetDSDir} / dshtml.dll / 1033 / HTML / LIBRARY.JS < prev   
Text File  |  2008-02-07  |  14KB  |  590 lines

  1. //var language = 'english';
  2. var language = 'french';
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. window.onresize = function() {
  13.   scaleDiv();
  14.   scaleDivTools();
  15.  
  16.   //scaleDivTools() ;
  17. };
  18.  
  19. window.onscroll = function() 
  20. {
  21.   scaleDiv();
  22. };
  23.  
  24. window.onload = function() 
  25. {
  26. SetLanguageFile();
  27.   scaleDiv();
  28.   document.body.onselectstart = function () 
  29.   {
  30.    return false;
  31.   }
  32.  
  33.   document.body.ondragstart = function () {
  34.      return false;
  35.    }
  36. };
  37.  
  38.  
  39. function SetLanguageFile()
  40. {
  41.  var newjs=document.createElement('script');
  42.   newjs.type='text/javascript';
  43.         switch (language)
  44.         {
  45.         
  46.         
  47.             case 'english':
  48.             //alert(language);
  49.              newjs.src='english.js';
  50.             break
  51.             case 'french':
  52.             //alert(language);
  53.              newjs.src='french.js';
  54.             break
  55.             default:
  56.             //alert(language);
  57.         }
  58.   document.getElementsByTagName('head')[0].appendChild(newjs);
  59.   
  60.   try
  61.   {
  62.    
  63.     SetLanguage(language);
  64.   
  65.   }catch(e)
  66.   {
  67.     //alert('No SetLanguage function, or id not found');
  68.   }
  69.   
  70. }
  71.  
  72.  
  73. // Add functions to window.onload 
  74. function AddLoadEvent(func) {
  75.   var oldonload = window.onload;
  76.   if (typeof window.onload != 'function') {
  77.     window.onload = func;
  78.   } else {
  79.     window.onload = function() {
  80.       if (oldonload) {
  81.         oldonload();
  82.       }
  83.       func();
  84.     }
  85.   }
  86. }
  87.  
  88.  
  89. function GrayOut(vis, options) {
  90.   // Pass true to gray out screen, false to ungray
  91.   // options are optional.  This is a JSON object with the following (optional) properties
  92.   // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  93.   // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  94.   // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  95.   // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  96.   // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  97.   // in any order.  Pass only the properties you need to set.
  98.   var darkDivId = 'dimmer';
  99.   var options = options || {}; 
  100.   var zindex = options.zindex || 50;
  101.   var opacity = options.opacity || 80;
  102.   var opaque = (opacity / 80);
  103.   var bgcolor = options.bgcolor ||  '#404040';
  104.   var dark=document.getElementById(darkDivId);
  105.   if (!dark) {
  106.     // The dark layer doesn't exist, it's never been created.  So we'll
  107.     // create it here and apply some basic styles.
  108.     // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
  109.     var tbody = document.getElementsByTagName("body")[0];
  110.     var tnode = document.createElement('div');           // Create the layer.
  111.         tnode.style.position='absolute';                 // Position absolutely
  112.         tnode.style.top='0px';                           // In the top
  113.         tnode.style.left='0px';                          // Left corner of the page
  114.         tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
  115.         tnode.style.display='none';                      // Start out Hidden
  116.         tnode.id=darkDivId;                   // Name it so we can find it later
  117.     tbody.appendChild(tnode);                            // Add it to the web page
  118.     dark=document.getElementById(darkDivId);  // Get the object.
  119.   }
  120.   if (vis) {
  121.   
  122.   
  123.     //alert(GetScrollTop());
  124.     //alert(screen.height +  " " +  document.body.scrollHeight + " " + document.body.offsetHeight );
  125.     
  126.     // Calculate the page width and height 
  127.     if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
  128.         var pageWidth = document.body.scrollWidth+'px';
  129.         var pageHeight = document.body.scrollHeight+'px';
  130.     } 
  131.     else if( document.body.offsetWidth ) {
  132.       var pageWidth = document.body.offsetWidth+'px';
  133.       var pageHeight = document.body.offsetHeight+'px';
  134.     } else {
  135.        var pageWidth='100%';
  136.        var pageHeight='100%';
  137.     }   
  138.     //set the shader to cover the entire page and make it visible.
  139.     dark.style.opacity=opaque;                      
  140.     dark.style.MozOpacity=opaque;                   
  141.     dark.style.filter='alpha(opacity='+opacity+')'; 
  142.     dark.style.zIndex=zindex;        
  143.     dark.style.backgroundColor=bgcolor;  
  144.     dark.style.width= '100%';
  145.     
  146. //    if(document.body.scrollHeight> 300)
  147. //    {
  148. //      dark.style.height= pageHeight;
  149. //    }else
  150. //    {
  151. //      dark.style.height= '100%';
  152. //    }
  153.     
  154.     dark.style.height= document.documentElement.clientHeight;
  155.     
  156.     
  157.     dark.style.display='block';        
  158.     //document.body.style.scrollbarBaseColor = '#404040';
  159.     
  160.     document.body.className = "body_gray_scrollbar";
  161.     document.documentElement.className = "body_gray_scrollbar";
  162.     
  163.     document.body.style.scrolling = 'no';
  164.     
  165.     scaleDiv();
  166.   } else {
  167.      dark.style.display='none';
  168.     //document.body.style.scrollbarBaseColor = '';
  169.     document.body.style.scrolling = 'auto';
  170.     document.body.className = "";
  171.     document.documentElement.className = "";
  172.     
  173.     
  174.     
  175.      
  176.   }
  177. }
  178.  
  179.  
  180.  
  181.  
  182.  
  183. function GetScrollTop()
  184. {
  185.  var theTop = 0;
  186.  if (document.documentElement && document.documentElement.scrollTop)
  187.       theTop = document.documentElement.scrollTop;
  188.  else if (document.body)
  189.       theTop = document.body.scrollTop
  190.  return theTop;
  191. }
  192.  
  193.  
  194. // This function begins the animation of the panel element by setting the height
  195. // to 1 pixel and setting the other animation properties. The return value is the
  196. // starting height of the panel to be used by the display element's internal
  197. // height tracking mechanism.
  198. function Animate_BeginAnimation(panelId)
  199. {
  200.   var panel = document.getElementById(panelId);
  201.   
  202.   Animate_SetPanelHeight(panelId, 1);
  203.  
  204.   panel.style.overflow = "hidden";
  205.   panel.style.display = "block";
  206.   
  207.   return 1;
  208. }
  209.  
  210. // This function ends the animation of the panel element by setting the overflow
  211. // of the panel to visible to ensure the panel makes it to it's correct height. The
  212. // return value of this function is the current height of the panel.
  213. function Animate_EndAnimation(panelId)
  214. {
  215.   var panel = document.getElementById(panelId);
  216.   
  217.   panel.style.overflow = "visible";
  218.   return panel.offsetHeight;
  219. }
  220.  
  221. function Animate_SetPanelHeight(panelId, height)
  222. {
  223.   var panel = document.getElementById(panelId);
  224.   panel.style.height = height + "px";
  225. }
  226.  
  227. function Get(id)
  228. {
  229.   return document.getElementById(id);
  230. }
  231.  
  232. function SetClass(id, className)
  233. {
  234.   var element = document.getElementById(id);
  235.   element.className = className;
  236. }
  237.  
  238. function SetDisplay(id, display)
  239. {
  240.   var element = document.getElementById(id);
  241.   element.style.display = display;
  242. }
  243.  
  244. // id : id of the control
  245. // value : boolean (true/ false )
  246. // UseBlock : bool ,  use  block to display
  247. function SetDisplayWidget( id , value, UseBlock )
  248. {
  249.   var type =  UseBlock ? "block" : "inline"; 
  250.   if ( value )
  251.    Get(id).style.display = type;
  252.   else
  253.    Get(id).style.display = "none";
  254. }
  255.  
  256. // id : id of the control
  257. // value : boolean (true/ false )
  258. function SetVisibility( id , value )
  259. {
  260.   if ( value )
  261.    Get(id).style.visibility = "visible";
  262.   else
  263.    Get(id).style.visibility = "hidden";
  264. }
  265.  
  266.  
  267.  
  268. function ToggleDisplay(id)
  269. {
  270.   var element = document.getElementById(id);
  271.   
  272.   if (element.style.display == "none")
  273.     element.style.display = "block";
  274.   else
  275.     element.style.display = "none";
  276. }
  277.  
  278.  
  279. function ToggleWidget(divid , imgid)
  280. {
  281.   var imgmax = "maximize.gif";
  282.   var imgmin = "minimize.gif";
  283.   
  284.   var img = document.getElementById(imgid);
  285.  
  286.   var element = document.getElementById(divid);
  287.   
  288.   if (element.style.display == "none")
  289.   {
  290.     element.style.display = "block";
  291.     img.src = imgmin;
  292.   }
  293.   else
  294.   {
  295.     element.style.display = "none";
  296.     img.src = imgmax;
  297.   }
  298. }
  299. function ToggleWidgetChild(id , imgid)
  300. {
  301.   var imgmax = "plus.gif";
  302.   var imgmin = "minus.gif";
  303.   
  304.   var img = document.getElementById(imgid);
  305.  
  306.   var element = document.getElementById(id);
  307.   
  308.   if (element.style.display == "none")
  309.   {
  310.     element.style.display = "block";
  311.     img.src = imgmin;
  312.   }
  313.   else
  314.   {
  315.     element.style.display = "none";
  316.     img.src = imgmax;
  317.   }
  318. }
  319.  
  320.  
  321. var  ns4 = (document.layers)? true:false;
  322. var ie4 = (document.all)? true:false;
  323.  
  324. function findPosX(id)
  325.   {
  326.   
  327.   var obj = document.getElementById(id);
  328.   
  329.     var curleft = 0;
  330.     if(obj.offsetParent)
  331.         while(1) 
  332.         {
  333.           curleft += obj.offsetLeft;
  334.           if(!obj.offsetParent)
  335.             break;
  336.           obj = obj.offsetParent;
  337.         }
  338.     else if(obj.x)
  339.         curleft += obj.x;
  340.     return curleft;
  341.   }
  342.  
  343.   function findPosY(id)
  344.   {
  345.    var obj = document.getElementById(id);
  346.     var curtop = 0;
  347.     if(obj.offsetParent)
  348.         while(1)
  349.         {
  350.           curtop += obj.offsetTop;
  351.           if(!obj.offsetParent)
  352.             break;
  353.           obj = obj.offsetParent;
  354.         }
  355.     else if(obj.y)
  356.         curtop += obj.y;
  357.     return curtop;
  358.   }
  359.   
  360.   
  361.   
  362.   
  363.   
  364. function URLEncode(text )
  365. {
  366.     // The Javascript escape and unescape functions do not correspond
  367.     // with what browsers actually do...
  368.     var SAFECHARS = "0123456789" +                    // Numeric
  369.                     "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +    // Alphabetic
  370.                     "abcdefghijklmnopqrstuvwxyz" +
  371.                     "-_.!~*'()";                    // RFC2396 Mark characters
  372.     var HEX = "0123456789ABCDEF";
  373.  
  374.     var plaintext = text;
  375.     var encoded = "";
  376.     for (var i = 0; i < plaintext.length; i++ ) {
  377.         var ch = plaintext.charAt(i);
  378.         if (ch == " ") {
  379.             encoded += "+";                // x-www-urlencoded, rather than %20
  380.         } else if (SAFECHARS.indexOf(ch) != -1) {
  381.             encoded += ch;
  382.         } else {
  383.             var charCode = ch.charCodeAt(0);
  384.             if (charCode > 255) {
  385.                 alert( "Unicode Character '" 
  386.                         + ch 
  387.                         + "' cannot be encoded using standard URL encoding.\n" +
  388.                           "(URL encoding only supports 8-bit characters.)\n" +
  389.                           "A space (+) will be substituted." );
  390.                 encoded += "+";
  391.             } else {
  392.                 encoded += "%";
  393.                 encoded += HEX.charAt((charCode >> 4) & 0xF);
  394.                 encoded += HEX.charAt(charCode & 0xF);
  395.             }
  396.         }
  397.     } // for
  398.  
  399. return encoded;
  400. //    document.URLForm.F2.value = encoded;
  401. //    return false;
  402. }
  403.  
  404. function URLDecode( text )
  405. {
  406.    // Replace + with ' '
  407.    // Replace %xx with equivalent character
  408.    // Put [ERROR] in output if %xx is invalid.
  409.    var HEXCHARS = "0123456789ABCDEFabcdef"; 
  410.    //var encoded = document.URLForm.F2.value;
  411.    var encoded = text;
  412.    var plaintext = "";
  413.    var i = 0;
  414.    while (i < encoded.length) {
  415.        var ch = encoded.charAt(i);
  416.        if (ch == "+") {
  417.            plaintext += " ";
  418.            i++;
  419.        } else if (ch == "%") {
  420.             if (i < (encoded.length-2) 
  421.                     && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
  422.                     && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
  423.                 plaintext += unescape( encoded.substr(i,3) );
  424.                 i += 3;
  425.             } else {
  426.                 alert( 'Bad escape combination near ...' + encoded.substr(i) );
  427.                 plaintext += "%[ERROR]";
  428.                 i++;
  429.             }
  430.         } else {
  431.            plaintext += ch;
  432.            i++;
  433.         }
  434.     } // while
  435.     
  436.     return plaintext;
  437. //   document.URLForm.F1.value = plaintext;
  438. //   return false;
  439. };
  440.  
  441.  
  442. function moveDiv(div, x , y)
  443. {
  444.   var o = Get(div);
  445.   o.style.left = x;
  446.   o.style.top = y;
  447. }
  448.  
  449.  
  450.  
  451.  
  452. //***************  Gray out Functions **********************************
  453.  
  454. //
  455. // global variables
  456. //
  457. //var isMozilla;
  458. var objDiv = null;
  459. var originalDivHTML = "";
  460. var DivID = "";
  461. var over = false;
  462.  
  463. //
  464. // dinamically add a div to 
  465. // dim all the page
  466. //
  467. function buildDimmerDiv()
  468. {
  469. //    document.write('<div id="dimmer" class="dimmer" style="width:'+ window.screen.width + 'px; height:' + window.screen.height +'px"></div>');
  470.     
  471.     document.write('<div id="dimmer" class="dimmer" style="width:100%; height:100%;  "></div>');
  472.     
  473. }
  474.  
  475. function init()
  476. {
  477.     // check browser
  478.     ///isMozilla = (document.all) ? 0 : 1;
  479.     //if (isMozilla) 
  480.     //{
  481.         //document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
  482.     //}
  483.  
  484.     //document.onmousedown = MouseDown;
  485.    // document.onmousemove = MouseMove;
  486.     //document.onmouseup = MouseUp;
  487.  
  488.     // add the div
  489.     // used to dim the page
  490. buildDimmerDiv();
  491.  
  492. }
  493.  
  494. // call init
  495. //init();
  496.  
  497.  
  498.  function GrayOut1(value)
  499. {
  500.     if(!value)
  501.     {
  502.      document.body.style.scrollbarBaseColor = ''; 
  503.     document.documentElement.scrollbarBaseColor = '';
  504.        document.getElementById('dimmer').style.visibility = "hidden";
  505.        //document.getElementById('dimmer').style.dislpay = "none";
  506.        
  507.       }
  508.       else
  509.       {
  510.        document.body.style.scrollbarBaseColor = '#404040';
  511.      document.documentElement.scrollbarBaseColor = '#404040';
  512.        document.getElementById('dimmer').style.visibility = "visible";
  513.       // document.getElementById('dimmer').style.dislpay = "block";
  514.       }
  515.       
  516.       scaleDiv() ;
  517. }
  518.  
  519.  
  520. function scaleDiv1() {
  521.   if (document.getElementById("dimmer") != null)
  522.   {
  523.     var scrollDiv = document.getElementById("dimmer");
  524.  
  525.     //
  526.     //alert(scrollDiv.style.visibility );
  527.     
  528.     if( scrollDiv.style.visibility != 'visible')
  529.        return;
  530.     
  531.     
  532.      
  533.   
  534.     var scalePercent = 0.80;//0.82
  535.     var wHeight  = document.body.offsetHeight;
  536.    // var wHeight  =document.documentElement.clientHeight;
  537.     
  538.     if ( (wHeight > 600) && (wHeight < 900) )
  539.     {
  540.       scalePercent = 0.86;//0.86
  541.     } 
  542.     else if ( wHeight > 900 )
  543.     {
  544.       scalePercent = 0.90;
  545.     }
  546.     
  547.     
  548.     
  549.     
  550.    //alert(wHeight);
  551.  
  552.     scrollDiv.style.height = wHeight; // GetScrollTop();// wHeight * scalePercent;
  553.   }
  554. }
  555.  
  556.  
  557.  
  558. function scaleDiv() 
  559. {
  560.   if (document.getElementById("dimmer") != null)
  561.   {
  562.     var wHeight  = document.documentElement.offsetHeight;
  563.     var wWidth  = document.documentElement.offsetWidth;
  564.     var scrollDiv = document.getElementById("dimmer");
  565.     
  566.     scrollDiv.style.height = wHeight + GetScrollTop();
  567.     scrollDiv.style.width = wWidth;
  568.   }
  569. }
  570.  
  571. function scaleDivTools() 
  572. {
  573.   if (document.getElementById("divChildTools_nav") != null)
  574.   {
  575.     var wHeight  = document.documentElement.offsetHeight;
  576.     var scrollDiv = document.getElementById("divChildTools_nav");
  577.  
  578.     scrollDiv.style.height = wHeight -  72;
  579.  
  580.   }    
  581. }
  582.  
  583. //***************  Gray out Functions **********************************
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.